<?php
/**
 * Title
 * Created by Jason.
 * User: Administrator
 * Date: 2019/12/10 0010
 * Time: 上午 11:25
 */

namespace app\index\controller;


class Mathematics
{
    public function quick_sort($arr)
    {
        if (count($arr) <= 1) {
            return $arr;
        }
        $middle = $arr[0];
        $left   = [];
        $right  = [];

        for ($i = 0; $i < count($arr); $i++) {
            if ($arr[$i] < $middle) {
                $left[] = $arr[$i];
            }
            if ($arr[$i] > $middle) {
                $right[] = $arr[$i];
            }
        }
        $left  = $this->quick_sort($left);
        $right = $this->quick_sort($right);
        return array_merge($left,array($middle),$right);
    }


}